<?php
/**
 * Created by PhpStorm.
 * User: pangmin
 * Date: 16/8/30
 * Time: 08:40
 */

namespace core\lib;


class config {
    public static $config;
    public static function get($name, $file){
        if(isset(self::$config[$file])){
            return self::$config[$file][$name];
        }else{
            $path = CORE.'/config/'.$file.'.php';
            if(is_file($path)){
                self::$config[$file] = include $path;
                if(isset(self::$config[$file][$name])){
                    return self::$config[$file][$name];
                }else{
                    throw new \Exception('没有找到配置项'.$name);
                }
            }else{
                throw new \Exception('没有找到配置文件'.$file);
            }
        }
    }

    public static function all($file){
        if(isset(self::$config[$file])){
            return self::$config[$file];
        }else{
            $path = CORE.'/config/'.$file.'.php';
            if(is_file($path)){
                self::$config[$file] = include $path;
                return self::$config[$file];
            }else{
                throw new \Exception('没有找到配置文件'.$file);
            }
        }
    }
}